# -*- coding: utf-8 -*-
# @Time    : 2018/8/16 17:11
# @Author  : 聂家利
# @Email   : 1073438012@qq.com
# @File    : helper.py
# @Software: PyCharm
import os, shutil ,json


def is_isbn_or_key(word):
    isbn_or_key = 'key'
    if len(word) == 13 and word.isdigit():
        isbn_or_key = 'isbn'
    short_word = word.replace('-', '')
    if '-' in word and len(short_word) == 10 and short_word.isdigit:
        isbn_or_key = 'isbn'
    return isbn_or_key


# def copyfile(srcfile, dstfile):
#     print(srcfile, dstfile)
#     if not os.path.isfile(srcfile):
#         result = 0
#     else:
#         fpath, fname=os.path.split(dstfile)    # 分离文件名和路径
#         if not os.path.exists(fpath):
#             os.makedirs(fpath)                 # 创建路径
#         shutil.copyfile(srcfile, dstfile)      # 复制文件
#         result = 1
#     return result
# def copyFile(sourceDir,  targetDir):  
  # try:    if os.path.exists(targetDir) and os.path.isfile(targetDir):
      #         os.chmod(targetDir, stat.S_IWRITE)       
      #         os.remove(targetDir)        
      #         shutil.copy(sourceDir, targetDir)
      #             else:        
      #         shutil.copy(sourceDir,  targetDir)    
  #         return True


# def movefile(srcfile, dstfile):
#     if not os.path.isfile(srcfile):
#         print("%s not exist!"%(srcfile))
#     else:
#         fpath, fname = os.path.split(dstfile)    # 分离文件名和路径
#         if not os.path.exists(fpath):
#             os.makedirs(fpath)                # v创建路径
#         shutil.move(srcfile, dstfile)          #移动文件